%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/pagination-when-inlined-backwards-nodes-only"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[59]<br />ᐳ: 10, 11, 71, 74, 75, 12, 14, 29<br />2: 63, 67<br />3: PgSelect[9]<br />ᐳ: Access[64], Access[68]<br />4: PgSelectRows[15]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 71, 64, 68<br /><br />ROOT __Item{1}ᐸ15ᐳ[16]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 71, 64, 16, 68<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[17]<br />1: <br />ᐳ: 18, 65, 69, 66, 70<br />2: Connection[25]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25, 70, 66<br /><br />ROOT Connection{2}ᐸ66ᐳ[25]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 60<br /><br />ROOT __Item{5}ᐸ30ᐳ[39]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 40, 60<br /><br />ROOT PgSelectSingle{5}ᐸmessagesᐳ[40]<br />1: <br />ᐳ: 48, 61, 62<br />2: PgSelectRows[55]<br />ᐳ: First[54], PgSelectSingle[56]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 56<br /><br />ROOT PgSelectSingle{6}ᐸusersᐳ[56]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket5
    Bucket5 --> Bucket6
    Bucket6 --> Bucket7

    %% plan dependencies
    PgSelect9[["PgSelect[9∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Constantᐸ2ᐳ[71]"]]:::plan
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda14{{"Lambda[14∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'YES' ]ᐳ[74]"}}:::plan
    PgSelectInlineApply63["PgSelectInlineApply[63∈0] ➊<br />More deps:<br />- Constantᐸ2ᐳ[71]"]:::plan
    PgSelectInlineApply67["PgSelectInlineApply[67∈0] ➊"]:::plan
    Object12 & Lambda14 & PgSelectInlineApply63 & PgSelectInlineApply67 --> PgSelect9
    Lambda29{{"Lambda[29∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[75]"}}:::plan
    PgSelectInlineApply59["PgSelectInlineApply[59∈0] ➊"]:::plan
    Lambda29 & PgSelectInlineApply59 --> PgSelectInlineApply63
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    PgSelectRows15[["PgSelectRows[15∈0] ➊"]]:::plan
    PgSelect9 --> PgSelectRows15
    Access64{{"Access[64∈0] ➊<br />ᐸ9.m.subqueryDetailsFor21ᐳ"}}:::plan
    PgSelect9 --> Access64
    Lambda29 --> PgSelectInlineApply67
    Access68{{"Access[68∈0] ➊<br />ᐸ9.m.subqueryDetailsFor34ᐳ"}}:::plan
    PgSelect9 --> Access68
    __Item16[/"__Item[16∈1]<br />ᐸ15ᐳ"\]:::itemplan
    PgSelectRows15 ==> __Item16
    PgSelectSingle17{{"PgSelectSingle[17∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item16 --> PgSelectSingle17
    Connection25[["Connection[25∈2]<br />ᐸ66ᐳ<br />More deps:<br />- Constantᐸ2ᐳ[71]"]]:::plan
    Lambda66{{"Lambda[66∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda66 --> Connection25
    List65{{"List[65∈2]<br />ᐸ64,16ᐳ"}}:::plan
    Access64 & __Item16 --> List65
    List69{{"List[69∈2]<br />ᐸ68,16ᐳ"}}:::plan
    Access68 & __Item16 --> List69
    PgClassExpression18{{"PgClassExpression[18∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle17 --> PgClassExpression18
    List65 --> Lambda66
    Lambda70{{"Lambda[70∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List69 --> Lambda70
    PgCursor45{{"PgCursor[45∈3]"}}:::plan
    First43{{"First[43∈3]"}}:::plan
    Access44{{"Access[44∈3]<br />ᐸ66.cursorDetailsᐳ"}}:::plan
    First43 & Access44 --> PgCursor45
    PgCursor47{{"PgCursor[47∈3]"}}:::plan
    Last46{{"Last[46∈3]"}}:::plan
    Last46 & Access44 --> PgCursor47
    ConnectionItems30[["ConnectionItems[30∈3]"]]:::plan
    Connection25 --> ConnectionItems30
    PageInfo33{{"PageInfo[33∈3]"}}:::plan
    Connection25 --> PageInfo33
    First35{{"First[35∈3]"}}:::plan
    PgSelectRows36[["PgSelectRows[36∈3]"]]:::plan
    PgSelectRows36 --> First35
    Lambda70 --> PgSelectRows36
    PgSelectSingle37{{"PgSelectSingle[37∈3]<br />ᐸmessagesᐳ"}}:::plan
    First35 --> PgSelectSingle37
    PgClassExpression38{{"PgClassExpression[38∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle37 --> PgClassExpression38
    Access41{{"Access[41∈3]<br />ᐸ25.hasNextPageᐳ"}}:::plan
    PageInfo33 o--o Access41
    Access42{{"Access[42∈3]<br />ᐸ25.hasPreviousPageᐳ"}}:::plan
    Access41 o--o Access42
    ConnectionItems30 --> First43
    Lambda66 --> Access44
    ConnectionItems30 --> Last46
    Access60{{"Access[60∈3]<br />ᐸ66.m.joinDetailsFor50ᐳ"}}:::plan
    Lambda66 --> Access60
    __Item39[/"__Item[39∈5]<br />ᐸ30ᐳ"\]:::itemplan
    ConnectionItems30 ==> __Item39
    PgSelectSingle40{{"PgSelectSingle[40∈5]<br />ᐸmessagesᐳ"}}:::plan
    __Item39 --> PgSelectSingle40
    List61{{"List[61∈6]<br />ᐸ60,40ᐳ"}}:::plan
    Access60 & PgSelectSingle40 --> List61
    PgClassExpression48{{"PgClassExpression[48∈6]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression48
    First54{{"First[54∈6]"}}:::plan
    PgSelectRows55[["PgSelectRows[55∈6]"]]:::plan
    PgSelectRows55 --> First54
    Lambda62{{"Lambda[62∈6]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda62 --> PgSelectRows55
    PgSelectSingle56{{"PgSelectSingle[56∈6]<br />ᐸusersᐳ"}}:::plan
    First54 --> PgSelectSingle56
    List61 --> Lambda62
    PgClassExpression57{{"PgClassExpression[57∈7]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle56 --> PgClassExpression57
    PgClassExpression58{{"PgClassExpression[58∈7]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression57 o--o PgClassExpression58

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect9,Access10,Access11,Object12,Lambda14,PgSelectRows15,Lambda29,PgSelectInlineApply59,PgSelectInlineApply63,Access64,PgSelectInlineApply67,Access68 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item16,PgSelectSingle17 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression18,Connection25,List65,Lambda66,List69,Lambda70 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems30,PageInfo33,First35,PgSelectRows36,PgSelectSingle37,PgClassExpression38,Access41,Access42,First43,Access44,PgCursor45,Last46,PgCursor47,Access60 bucket3
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item39,PgSelectSingle40 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression48,First54,PgSelectRows55,PgSelectSingle56,List61,Lambda62 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression57,PgClassExpression58 bucket7

